/*
 * TM1640.h
 *
 *  Created on: Sep 28, 2024
 *      Author: Administratorw
 */

#ifndef BSP_TM1640_H_
#define BSP_TM1640_H_

#include "stm32f1xx_hal.h"
#include "main.h"
#include "stdio.h"
#include "usart.h"
#define   	ADDR_START1640        0XC0
#define  	RX_CMD_LEN  	18
#define     DSP1640_DIS     0
#define     DSP1640_ENB     1

/*
控制显示
0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f 分别对应
1/16,  2/16,  4/16,  10/16, 11/16, 12/16, 13/16, 14/16

设置数据，0x40,0x44分别对应地址自动加一和固定地址模式
*/

#define 		SET_DATA_ORDER     	 0X40  //数据命令设置 地址自动加1
#define		        SET_DISPLAY        	 0X8F  //显示命令控制  脉冲宽度14/16
#define 		SET_DSP1640_DIS          0x80  //显示关控制


#define     VT_DLY1640           150//80//10//2000
#define     VT_DLYNOP            10//80//10

#define TM1640SLK_LOW      HAL_GPIO_WritePin(TM1640_SCLK_GPIO_Port, TM1640_SCLK_Pin,GPIO_PIN_RESET)
#define TM1640SLK_HING     HAL_GPIO_WritePin(TM1640_SCLK_GPIO_Port, TM1640_SCLK_Pin,GPIO_PIN_SET)
#define TM1640DAT_LOW      HAL_GPIO_WritePin(TM1640_DIN_GPIO_Port, TM1640_DIN_Pin,GPIO_PIN_RESET)
#define TM1640DAT_HING     HAL_GPIO_WritePin(TM1640_DIN_GPIO_Port, TM1640_DIN_Pin,GPIO_PIN_SET)


void TM1640_GPIO_Config(void);
void Nop1640(uint16_t T_Dly);
void TM1640Start(void);
void TM1640Stop(void);
void TM1640_display(void);
void Running_state(uint8_t state);
void TM1640WriteByte(uint8_t date);
void TM1640_Init(uint8_t InValue);
void TM1640_SendData(uint8_t Addr1640,uint8_t *a,uint8_t DataLong);
void TM1640_TEST(void);
void display_time(void);
void Uart_RxAgain(UART_HandleTypeDef *huart);

#endif /* BSP_TM1640_H_ */
